//
//  CellHeadView.m
//  FM
//
//  Created by MB__Lee on 2018/4/9.
//  Copyright © 2018年 MB__Lee. All rights reserved.
//

#import "CellHeadView.h"


@interface CellHeadView()
@property (weak, nonatomic) IBOutlet UILabel *summary;
@property (weak, nonatomic) IBOutlet UILabel *brokenReason;

@property (weak, nonatomic) IBOutlet UILabel *price;


@property(nonatomic,assign)BOOL isSelected;


@end

@implementation CellHeadView

-(void)awakeFromNib{
    [super awakeFromNib];
    
    UITapGestureRecognizer *swipe = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(leftSwipe:)];
    
    self.userInteractionEnabled = YES;
    
    [self addGestureRecognizer:swipe];
    
}

-(void)setModel:(OutModel *)model{
    _model = model;
    
    self.summary.text = model.projectName;
    
    
//    self.brokenReason.text = model.rason;
    self.brokenReason.text = [NSString stringWithFormat:@"故障描述%@",model.rason];
    
    self.price.text = [NSString stringWithFormat:@"￥%@",model.hourPrice];
}


- (IBAction)TableViewHeadButtonAction:(id)sender {
    if (_headAction) {
        _headAction();
    }
    
}


//sectionHeader 动画
-(void)leftSwipe:(UISwipeGestureRecognizer *)gesture{
    NSLog(@"%@",gesture.view);
    
    
    if (!_isSelected) {
       
        [UIView animateWithDuration:0.5 animations:^{
            gesture.view.frame = CGRectMake(-100, 0, 420, 40);
        }];
    }else{
        
        [UIView animateWithDuration:0.5 animations:^{
            self.frame = CGRectMake(0, 0, 420, 40);
        }];
    }
    _isSelected = !_isSelected;
    
    
    
    
}
- (IBAction)deleteBTN:(UIButton *)sender {
    [UIView animateWithDuration:0.5 animations:^{
        self.frame = CGRectMake(0, 0, 420, 40);
    } completion:^(BOOL finished) {
        _isSelected = NO;
    }];
    
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
